package zk.tool.util;

import javafx.fxml.FXMLLoader;
import javafx.stage.Modality;
import javafx.stage.Stage;
import zk.tool.App;

import java.net.URL;

public class StageUtil {

    public static Stage createDialogStage(Stage parent, String title) {
        Stage stage = new Stage();
        stage.setTitle(title);
        stage.initOwner(parent == null ? App.primaryStage : parent);
        stage.centerOnScreen();
        stage.initModality(Modality.APPLICATION_MODAL);
        stage.setResizable(false);
        stage.setFullScreen(false);
        return stage;
    }

    public static FXMLLoader loadFxml(String fxmlName) {
        URL connectResource = StageUtil.class.getClassLoader().getResource(fxmlName);
        return new FXMLLoader(connectResource);
    }

}
